# Definition for singly-linked list.

# class ListNode(object):

# def __init__(self, x):

# self.val = x

# self.next = None

class Solution(object):

def deleteDuplicates\(self, head\):

    """

    :type head: ListNode

    :rtype: ListNode

    """

    lst=\[\]

    temp=ListNode\(0\)

    result=temp



    if head == None:

        return None

    else:

        while\(head.next != None\):

            if head.val not in lst:

                lst+=\[head.val\]

            head=head.next

        if head.val not in lst:

            lst+=\[head.val\]



        for i in lst:

            temp.next=ListNode\(i\)

            temp=temp.next



    return result.next

results matching ""

    No results matching ""